/**
  ******************************************************************************
  * @file    camera.h
  * @author  W. Boerendans
  * @version V1.0.0
  * @date    21-november-2013
  * @brief   This file provides ITM Trace options
  *         
  * <h2><center>&copy; COPYRIGHT 2013 W. Boerendans</center></h2>
  ******************************************************************************  
  */ 

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef SCCB_H_
#define SCCB_H_

/* Public includes -----------------------------------------------------------*/
#include <stm32f4xx.h>

/* Public defines ------------------------------------------------------------*/
#define SCCB_I2Cx								I2C2
#define SCCB_RCC_APBxPeriph			RCC_APB1Periph_I2C2

// 0011 1100 -> 0011 1100
// 0011 1101 -> 1011 1100
#define SCCB_CAM_WR_ADDRESS         0x60
#define SCCB_CAM_RD_ADDRESS    	    0x61
#define SCCB_CAM_SPEED      		200000  //200kHz, 400000 for 400kHz
#define SCCB_CAM_TIMEOUT    		1000

#define TIMEOUT_MAX        			10000
#define WRITE_DELAY        			5000

/* Registers */
#define SCCB_GAIN							0x00
#define SCCB_BLUE 							0x01
#define SCCB_RED 							0x02
#define SCCB_VREF		 					0x03					
#define SCCB_COM1 							0x04
#define SCCB_COM2
#define SCCB_COM3
#define SCCB_COM4
#define SCCB_COM5
#define SCCB_COM6
#define SCCB_COM7							0x12
#define SCCB_COM8							0x13
#define SCCB_COM9							0x14
#define SCCB_COM10							0x15
#define SCCB_COM11
#define SCCB_COM12
#define SCCB_COM13
#define SCCB_COM14							0x3E
#define SCCB_COM15							0x40
#define SCCB_COM16							0x41
#define SCCB_COM17							0x42

#define SCCB_CLKRC  						0x11
#define SCCB_MIDH   						0x1C
#define SCCB_MIDL   						0x1D

#define SCCB_POIDX							0x72
#define SCCB_PCKDV							0x73
#define SCCB_XINDX							0x74
#define SCCB_YINDX							0x75


/* Public functions ---------------------------------------------------------*/
/**
 * @name sccbInit
 * @brief Configuration of I2C (= SCCB)
 */
void sccbInit(void);

/**
 * @name sccbWrite
 * @brief Write to SCCB device using I2C
 * @param[in] reg 		Registeraddress
 * @param[in] data 		Data
 */
uint8_t sccbWrite(uint8_t reg, uint8_t data);

/**
 * @name sccbRead
 * @brief Reading from SCCB device using I2C
 * @param[in] reg 		Registeraddress
 * @ret Returns data from registeraddress
 */
uint8_t sccbRead(uint8_t reg);

#endif /*SCCB_H_*/

